home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / prgtools / programm.ing / sources.arc / DANG_SRC.LZH / LSOUND.C < prev    next >
Encoding:
C/C++ Source or Header  |  1993-09-20  |  3.4 KB  |  120 lines

  1. extern long addr;
  2. #include <osbind.h>
  3.  
  4.  
  5. /* Loads up PLAY.PRG as TSR. and will call it with arguments.
  6.  
  7.    Now you can include sounds in the form of *.SND files in your code!
  8.  
  9.    Say you are writing a utility program and want to spice it up a bit.
  10.    If the user entered a wrong command, you could play a .SND file 
  11.    that says 'WHAT THE HELL ARE YOU DOING?' 
  12.   
  13.    It adds a nice touch.
  14.  
  15.    
  16.  
  17.  
  18.   ** NOTE ** the format of the command line argument is 
  19.              FILENAME.EXT xxxx
  20.  
  21.              where filename is the FILE.SND 
  22.              and   xxxx     is the Freq. you want to play it as.
  23.  
  24.              ex:   HITHERE.SND 6500 
  25.  
  26.                    will play the file "hithere" at 6500Hz
  27.  
  28.     Thats all there is to it! Enjoy. Jeff Bilger TAMU 3/28/93 3:40am                        
  29. */
  30.  
  31.  
  32.  
  33.   
  34. load_player_as_tsr()
  35. {
  36.   char   work[20];                      /* For conv. C to Pascal like string */
  37.  
  38.     
  39.      addr = Pexec(3,"player",work,"");    /* load it as TSR */
  40.                                           /* addr holds addr of its basepage*/
  41.    printf("Loaded at:%lx\n",addr);
  42.  
  43.  
  44. }
  45.  
  46.  
  47.  
  48. /********************************************************/
  49. /* The COMMAND argument of Pexec requires that the string be in
  50.    the Pascal-like format. ie 1st element in string holds the 
  51.    length of the string.
  52. */
  53.  
  54. convert_string(dest , source )
  55. char dest[];
  56. char source[];
  57.  
  58. {
  59.  
  60.    dest[0] = strlen(source);          /* place length of string in 1st cell of array */
  61.    strcpy(&dest[1],source);           /* copy rest of string */
  62.   printf("length:%d %s\n",dest[0],dest);
  63. }
  64.   
  65. /*********************************************/
  66. /* this code will place a *.SND file in the Command
  67.    line arg and play it
  68.  
  69.  */
  70.  
  71. invoke_tsr(a)
  72. char a[];
  73. {
  74.  long cline;                            /* temp addr. Used to store new *.SND file in command line*/
  75.  char *ptr;
  76.  char   work[20];                      /* For conv. C to Pascal like string */
  77.  int x;
  78.  char ui;
  79.   
  80.   
  81.  
  82.   convert_string( work, a);          /* convert to Pascal like string */
  83.       cline = addr;                  /* get addr of basepage */
  84.       cline += 128;                  /* add 128 byte offset,so now
  85.                                         cline points to Command_line*/
  86.       ptr = (char *) cline;
  87. printf("******ADDRS*******************\n");
  88. printf("Loaded to:%lx\n",addr);
  89. printf("Basepage%lx\n",ptr);
  90. printf("******************************\n");     
  91.    /* clear out command line */
  92.   
  93.     
  94.  
  95.       
  96.       strcpy(cline,work);            /*copy new ttp info to command
  97.                                        line. ie place string *.SND there */
  98.  
  99.    /** display command line **/
  100. printf("*******CONTENTS*************************\n");
  101.    printf("Contents of command line:\n");
  102.    for(x=0;x<20;x++)
  103.     printf("%d",*(ptr++));
  104.   ptr = (char *) cline;
  105.   printf("\n");
  106.     for(x=0;x<15;x++)
  107.     printf("%c",*(ptr++));
  108. printf("****************************************\n");
  109.     ptr = (char *) cline;
  110.     
  111.      scanf("%c",&ui);
  112.    Pexec(4,"",(long *)addr,"");  /* invoke the TSR prg. We need to tell it */
  113.                                  /* which one to invoke. We send the basepage addr*/
  114.                                  /* of the prg we want to invoke. We send it*/
  115.                                  /* to the command line string */     
  116.                                  /* we must typecast it */
  117.   
  118. }
  119.  
  120.